package com.haixiaoke.saas.enterprise.messageCenter.controller;

import cn.hutool.core.util.StrUtil;
import com.haixiaoke.saas.common.annotation.TenantScope;
import com.haixiaoke.saas.common.core.domain.AjaxResult;
import com.haixiaoke.saas.common.tenant.TenantContext;
import com.haixiaoke.saas.messageCenter.domain.PushCondition;
import com.haixiaoke.saas.messageCenter.service.IPushConditionService;
import com.haixiaoke.saas.system.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * 推送条件信息Controller
 *
 * @author xiaolong
 * @date 2024-11-26
 */
@RestController
@RequestMapping("/enterprise/messageCenter/pushCondition")
public class EnterprisePushConditionController extends BaseController {
    @Autowired
    private IPushConditionService pushConditionService;


    /**
     * 查询机构下推送条件信息
     */
    @GetMapping("/info")
    @TenantScope
    public AjaxResult info(PushCondition pushCondition) {
        if (StrUtil.isEmpty(pushCondition.getMessageType())) {
            return error("请选择消息类型");
        }
        pushCondition.setTenantId(TenantContext.getTenantId());
        List<PushCondition> list = pushConditionService.selectPushConditionList(pushCondition);
        return success(list);
    }
}
